package cate.game.role.res.worldtree.msg;

import cate.common.annotation.FuncOpenJudge;
import cate.common.table.d.GDFunc;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBWorldTree;
import cate.game.role.Role;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "添加 英雄  共享の 请求")
public class HeroShareAddReq implements MsgInput {
    @NoteField(value = "英雄id", detail = "英雄id")
    public String heroUid;

    @NoteField(value = "位置", detail = "位置")
    public int pos;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        Role role = cc.getRole();
        GameResult<Void> rr = role.getRes().worldTree.heroShare.addHeroShare(heroUid, pos);
        if (rr.ok()) {
            role.getRes().worldTree.heroShare.update2ClientByOnlyId(heroUid);
            cc.sendNow(new HeroShareAddResp(heroUid, pos));
            role.getBase().updatePower();
            cc.sendNow(new HeroShareDataResp(role.getRes().worldTree.heroShare));
        } else {
            game.notice.message(role, rr.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBWorldTree.ADD_SHARE_REQ;
    }
}
